import React from 'react'
import {  BrowserRouter, Route ,Switch,Redirect} from 'react-router-dom'
import App from './pages/app'
import Login from './pages/login'
import Home from './pages/home'

export default function IRouter () {
  return <BrowserRouter>
    {/* 加载子路由 */}
    <Switch>
        <Route path="/" exact component={App}></Route>
        <Route path="/login" component={Login}></Route>
      <Route path="/home" render={() => {
        return localStorage.getItem("token") ? (<Home></Home>) : (<Redirect to="/login"></Redirect>)
        }}></Route>
    </Switch>
  </BrowserRouter>
}